package com.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.RoleBean;
import com.project.service.IRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Title: RoleController
 * @Package: com.project.controller
 * @Description:
 * @Author: Liang-Xie
 */
@SuppressWarnings("all")
@RestController
@RequestMapping("role")
public class RoleController {
    @Autowired
    private IRoleService roleService;

    @RequestMapping("findAll")
    public List<RoleBean> findAll() {
        return roleService.findAll();
    }

    @RequestMapping("findByItem")
    public IPage<RoleBean> findByItem(Integer pageNO) {
        return roleService.findByItem(pageNO);
    }

    @RequestMapping("add")
    public String add(RoleBean role, Integer[] gradeIdArray) {
        roleService.add(role, gradeIdArray);
        return "ok";
    }

    @RequestMapping("del")
    public String del(Integer roleId) {
        roleService.del(roleId);
        return "ok";
    }

    @RequestMapping("findById")
    public RoleBean findById(Integer roleId) {
        return roleService.findById(roleId);
    }

    @RequestMapping("update")
    public String update(Integer roleId, Integer[] gradeIdArray) {
        roleService.update(roleId, gradeIdArray);
        return "ok";
    }
}
